/*
 * Filename PatientMapping.java 2021年09月29日
 * Copyright © Ehome Co.Ltd. All Rgiths Reserved.
 * @author wuyingchao
 */
package com.ehome.poct.core.dao.mapping;

import com.ehome.poct.core.api.dto.patient.Patient;
import com.ehome.poct.core.api.vo.patient.PatientDetailVO;
import com.ehome.poct.core.dao.entity.TermPatientDO;
import org.mapstruct.Mapper;
import org.mapstruct.Mapping;

/**
 * 患者 mapping
 *
 * @author wyc
 * @since 2021/09/29 15:54
 **/
@Mapper(componentModel = "spring")
public interface PatientMapping {

    @Mapping(target = "patientId", source = "termPatientId")
    @Mapping(target = "clinicId", source = "termClinicId")
    @Mapping(target = "userName", source = "name")
    @Mapping(target = "mobilePhone", source = "phone")
    @Mapping(target = "userAge", source = "age")
    @Mapping(target = "userMonth", source = "month")
    @Mapping(target = "userSex", source = "sex")
    PatientDetailVO toVO(TermPatientDO entity);

    @Mapping(target = "patientId", source = "id")
    @Mapping(target = "userName", source = "detail.name")
    @Mapping(target = "mobilePhone", source = "detail.phone")
    @Mapping(target = "userSex", source = "detail.sex.value")
    @Mapping(target = "userAge", source = "detail.age.year")
    @Mapping(target = "userMonth", source = "detail.age.month")
    PatientDetailVO to(Patient patient);

}